var pagemain=1;
var datamain={};
var celldata=new Array();
var enddata=0;
var cellnum=0;
var fistcheck=0;
var lastcheck=0;
var process=0;
var targetdiv='';
var checkfirstrowdata=0;


    var _old = $.uniquedata;

    $.uniquedata = function(arr){

        // do the default behavior only if we got an array of elements
        if(typeof arr[0] != 'undefined'){
        if (!!arr[0].nodeType){
            return _old.apply(this,arguments);
        } else {
            // reduce the array to contain no dupes via grep/inArray
            return $.grep(arr,function(v,k){
                return $.inArray(v,arr) === k;
            });
        }
        }
        
    };
function getUrlVars() {
    var vars = {};
    var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
        vars[key] = value;
    });
    return vars;
}
if(getUrlVars()["page"])
{
pagemain=parseInt(getUrlVars()["page"],10);
}


function nextData(num)
{
var num=""+num;
var nextnum=celldata[($.inArray(num, celldata) + 1) % celldata.length]; 


return nextnum; 
}
function prevData(num)
{
var num=""+num;
var prevnum=celldata[($.inArray(num, celldata) - 1 + celldata.length) % celldata.length];
if(prevnum==lastcheck)
{
prevnum=0;
}
return prevnum;

}
var nowproductid=0;
function setnowdata(productid,swap)
{

//datasettoolproduct(productid);
var swapdata;
if(swap)
{
swapdata=swap;
}else
{
swapdata=0;
}
var nextproductid=nextData(productid);


if(swapdata!=2)
{
setpopupdata(nextproductid,'#main-right');
}

if(nextproductid!=fistcheck)
{

$('.ovlPopLd .wrpLdTl .slideLd .btnIco.slideLdR').attr('onclick','changepagemain('+nextproductid+',1)');
$('.ovlPopLd .wrpLdTl .slideLd .btnIco.slideLdR').css('opacity', 1);
//console.log(1);
}else
{
pagemain--;
$('.ovlPopLd .wrpLdTl .slideLd .btnIco.slideLdR').attr('onclick','void(0)');
$('.ovlPopLd .wrpLdTl .slideLd .btnIco.slideLdR').css('opacity', 0.3);

}

var prevproductid=prevData(productid);

if(prevproductid!=0&&swapdata!=1)
{
setpopupdata(prevproductid,'#main-left');
}



if(prevproductid!=0)
{
$('.ovlPopLd .wrpLdTl .slideLd .btnIco.slideLdL').attr('onclick','changepagemain('+prevproductid+',2)');
$('.ovlPopLd .wrpLdTl .slideLd .btnIco.slideLdL').css('opacity', 1);

}else
{

$('.ovlPopLd .wrpLdTl .slideLd .btnIco.slideLdL').attr('onclick','void(0)');
$('.ovlPopLd .wrpLdTl .slideLd .btnIco.slideLdL').css('opacity', 0.3);

}



}
function swapnextdata(productid,swap)
{
var swapdata;
if(swap)
{
swapdata=swap;
}
else
{
swapdata=0;
}
datasettoolproduct(productid);
var nextproductid=nextData(productid);
if(nextproductid==fistcheck)
{
if(enddata==0)
{
pagemain++;

var jqxhr =getmainproduct();

jqxhr.done(function() {

setnowdata(productid,swapdata);
process=0;

});

}else
{
setnowdata(productid,swapdata);
process=0;

}


}
else
{
if(swapdata!=2)
{
setpopupdata(nextproductid,'#main-right');
}

var prevproductid=prevData(productid);
if(prevproductid!=0&&swapdata!=1)
{
setpopupdata(prevproductid,'#main-left');
}



$('.ovlPopLd .wrpLdTl .slideLd .btnIco.slideLdR').css('opacity', 1);
$('.ovlPopLd .wrpLdTl .slideLd .btnIco.slideLdL').css('opacity', 1);
$('.ovlPopLd .wrpLdTl .slideLd .btnIco.slideLdR').attr('onclick','changepagemain('+nextproductid+',1)');
if(prevproductid!=0)
{
$('.ovlPopLd .wrpLdTl .slideLd .btnIco.slideLdL').attr('onclick','changepagemain('+prevproductid+',2)');
}else
{
$('.ovlPopLd .wrpLdTl .slideLd .btnIco.slideLdL').attr('onclick','void(0)');
$('.ovlPopLd .wrpLdTl .slideLd .btnIco.slideLdL').css('opacity', 0.3);

}
process=0;

}

}
function closepopupsubmain()
{
 if (!!(window.history && history.pushState))
 {
 
 window.history.pushState("object or string", "Title", checknowurl);
 }


$('.wrpVdoLdcheckrow div div').remove();


$.each($('.wrpVdoLdcheckrow video'), function(index ) {
var myVideo=document.getElementById($(this).attr('id'));
myVideo.pause();

});

}

function datasettoolproduct(productid)
{
var datanow=datamain[productid];
 if (!!(window.history && history.pushState))
 {
window.history.pushState("object or string", "Title", "/post/"+productid);
 }



//console.log(datanow.countlike);
//$('.ovlPopLd .btnNumLikeFlw').html(datanow.countlike);
$('.ovlPopLd .genMenuListPop.numLikeFlw.numLike .btnNumLikeFlw').html(datanow.countlike+' Like');
$('.ovlPopLd .genMenuListPop.numBmFlw.numBm .btnNumBmFlw').html(datanow.countbookmark+' Bookmark');


//$('.ovlPopLd .genMenuListPop.numLikeFlw.numLike .btnNumLikeFlw').attr("title",datanow.countlike+' Like');


if(datanow.checklike)
{
$('.ovlPopLd  .wrpLikeLd .btnIco.unLikeLd.clBd3.bdBtm span.ico').addClass('icoLikeLd');
}
else
{
$('.ovlPopLd  .wrpLikeLd .btnIco.unLikeLd.clBd3.bdBtm span.ico').removeClass('icoLikeLd');
}

if(datanow.checkbookmark)
{
$('.ovlPopLd  .wrpBmLd .btnIco.unBmLd.clBd3.bdBtm span.ico').addClass('icoUnBmLd');
}else
{
$('.ovlPopLd  .wrpBmLd .btnIco.unBmLd.clBd3.bdBtm span.ico').removeClass('icoUnBmLd');
}

//console.log(datanow.countfollow);

$('.ovlPopLd .genMenuListPop.numLikeFlw.numFlw .btnNumLikeFlw').html(datanow.countfollow+' Follow');

//$('.ovlPopLd .genMenuListPop.numLikeFlw.numFlw .btnNumLikeFlw').attr("title",datanow.countlike+' Follow');
if(datanow.checkfollow==3)
{
//$('.ovlPopLd  .wrpFlwLd .btnIco.flwLd.clBd3.bdBtm span.ico').addClass('icoFlwLd');
$('.ovlPopLd .wrpFlwLd  span.ico').addClass('icoFlwWaitLd');
}else if(datanow.checkfollow)
{

$('.ovlPopLd .wrpFlwLd  span.ico').addClass('icoFlwedLd');

}
else
{
//$('.ovlPopLd  .wrpFlwLd .btnIco.flwLd.clBd3.bdBtm span.ico').removeClass('icoFlwLd');
$('.ovlPopLd .wrpFlwLd  span.ico').removeClass('icoFlwedLd');
$('.ovlPopLd .wrpFlwLd  span.ico').removeClass('icoFlwWaitLd');
}

$('.ovlPopLd .wrpInTlLd.wrpLikeLd').attr('onclick','favfunction('+datanow.productid+')');
$('.ovlPopLd .wrpInTlLd.wrpBmLd').attr('onclick','likefunction('+datanow.productid+')');
$('.ovlPopLd .wrpInTlLd.wrpFlwLd').attr('onclick','followfunction('+datanow.productid+','+datanow.createby+')');


$('.ovlPopLd .shrMenuListPop.shrLdPop .wrpMenuListPop .mLP.clBg5.clTxt3.fs04 .btnMLP:eq(0)').attr('onclick','sharefunction(0,'+datanow.productid+',\'post\')');
$('.ovlPopLd .shrMenuListPop.shrLdPop .wrpMenuListPop .mLP.clBg5.clTxt3.fs04 .btnMLP:eq(1)').attr('onclick','sharefunction(1,'+datanow.productid+',\'post\')');
$('.ovlPopLd .shrMenuListPop.shrLdPop .wrpMenuListPop .mLP.clBg5.clTxt3.fs04 .btnMLP:eq(2)').attr('onclick','sharefunction(2,'+datanow.productid+',\'post\')');
if(roleidinfo>2)
{
$('.ovlPopLd .shrMenuListPop.shrLdPop .wrpMenuListPop .mLP.clBg5.clTxt3.fs04 .btnMLP:eq(3)').attr('onclick','sharefunction(3,'+datanow.productid+',\'post\')');
}else
{
$('.ovlPopLd .shrMenuListPop.shrLdPop .wrpMenuListPop .mLP.clBg5.clTxt3.fs04 .btnMLP:eq(3)').hide();

}

$('.ovlPopLd .shrMenuListPop.shrLdPop .wrpMenuListPop .mLP.clBg5.clTxt3.fs04 .btnMLP:eq(4)').attr('onclick','sharefunction(4,'+datanow.productid+',\'post\')');

$('.ovlPopLd .shrMenuListPop.shrLdPop .wrpMenuListPop .mLP.clBg5.clTxt3.fs04 .btnMLP:eq(5)').attr('onclick','sharefunction(5,'+datanow.productid+',\'post\')');


var clip = null;
clip = new ZeroClipboard.Client();
clip.setHandCursor( true );
clip.addEventListener('mouseOver', function (client) {
                // update the text on mouse over
               // console.log('test zero');
                clip.setText( baseinfo+'/post/'+datanow.productid );
              //   $('.shrMenuListPop.shrLdPop').removeClass('sortHomeBlock');
            });
            
clip.addEventListener( 'complete', function(client, text) {
                $('.shrMenuListPop.shrLdPop').removeClass('sortHomeBlock');
            } );

//console.log(datanow.productid);
clip.glue( 'd_clip_button', 'd_clip_container' );



// //$('.ovlPopLd .shrMenuListPop.shrLdPop .wrpMenuListPop .mLP.clBg5.clTxt3.fs04 .btnMLP:eq(5)').zclip('remove');
// $('.ovlPopLd .shrMenuListPop.shrLdPop .wrpMenuListPop .mLP.clBg5.clTxt3.fs04 .btnMLP:eq(5)').zclip({
//path:'/js/vendor/zero/ZeroClipboard.swf',
//copy:function(){
//console.log('checkpost');
//return baseinfo+'/post/'+productid;

//}
//});

//console.log('test');

$('.ovlPopLd .genMenuListPop.rptMenu .wrpMenuListPop .mLP.clBg5.clTxt3.fs04 .btnMLP:eq(0)').attr('onclick','openreport(1,'+datanow.productid+',0)');
$('.ovlPopLd .genMenuListPop.rptMenu .wrpMenuListPop .mLP.clBg5.clTxt3.fs04 .btnMLP:eq(1)').attr('onclick','openreport(2,'+datanow.productid+',0)');

}
function copyToClipboardCrossbrowser(s) {           
      //var  s = document.getElementById(s).value;               

    



    }
function statdataweb(productid)
{
$.post(serviceinfo+'statdataweb', { productid:productid }, function(data) { 


});

}

function openpopupdata(productid)
{
setpopupdata(productid);
swapnextdata(productid);
$('.ovlPopLd').show();


initalldata();


}
var startscrollnow=1;
function initalldata()
{
//initmapdata();
initvideodata();
initmapdataroute();
initmapdataroute2();
initreservationregis();
initvideomp4data();
//console.log('test');
//setTimeout('$( "#main-middle .wrpUoutLd .wrpUinLd" ).focus();',1000);
if(NameDmconnex=='Canonlife')
{
$(".ovlPopLd #main-middle .wrpUinLd").mCustomScrollbar("destroy");
if(startscrollnow)
{
startscrollnow=0;
var ua = navigator.userAgent.toLowerCase();

var isAndroid = ua.indexOf("android") > -1; //&& ua.indexOf("mobile");
var isIos =( navigator.userAgent.match(/(iPad|iPhone|iPod)/g) ? true : false );
if(isAndroid||isIos) {

}
else
{
setTimeout('rowscrolllanding();',1000);
}

}
}

}
function rowscrolllanding()
{

scrollLandingUi();
startscrollnow=1;



}
function inArray(needle, haystack) {
    var length = haystack.length;
    for(var i = 0; i < length; i++) {
        if(typeof haystack[i] == 'object') {
            if(arrayCompare(haystack[i], needle)) return true;
        } else {
            if(haystack[i] == needle) return true;
        }
    }
    return false;
}
function changepagemain(productid,sidedata)
{

statdataweb(productid);

if(process==0)
{
process=1;
if(sidedata==1)
{
  $('#main-left').css('opacity',0);
  $('#main-middle').addClass('frameleft');
  $('#main-middle').css('opacity',1).removeClass("framemiddle");
  $('#main-middle').attr('id','main-left_bk');
  $('#main-right').css('opacity',1).addClass('framemiddle').removeClass("frameright");
  $('#main-right').attr('id','main-middle');
  $('#main-left').removeClass("frameleft").attr('id','main-right');
  $('#main-right').addClass('frameright');
  $('#main-left_bk').attr('id','main-left');
 // $('#main-left').css('opacity',0);
}else
{
  $('#main-right').css('opacity',0);
  $('#main-middle').addClass('frameright');
  $('#main-middle').css('opacity',1).removeClass("framemiddle");
  $('#main-middle').attr('id','main-right_bk');
  $('#main-left').css('opacity',1).addClass('framemiddle').removeClass("frameleft");
  $('#main-left').attr('id','main-middle');
  $('#main-right').removeClass("frameright").attr('id','main-left');
  $('#main-left').addClass('frameleft');
  $('#main-right_bk').attr('id','main-right');
  //$('#main-right').css('opacity',0);
}



//console.log(1);
//console.log(process);
swapnextdata(productid,sidedata);
initalldata();

 //process=0;


}
//console.log(productid+" "+sidedata);




}

var allowuser={};
function isFunctionA(object) {
 return object && getClass.call(object) == '[object Function]';
}

function loadjscssfile(filename, filetype){
 if (filetype=="js"){ //if filename is a external JavaScript file
  var fileref=document.createElement('script')
  fileref.setAttribute("type","text/javascript")
  fileref.setAttribute("src", filename)
 }
 else if (filetype=="css"){ //if filename is an external CSS file
  var fileref=document.createElement("link")
  fileref.setAttribute("rel", "stylesheet")
  fileref.setAttribute("type", "text/css")
  fileref.setAttribute("href", filename)
 }
 if (typeof fileref!="undefined")
  document.getElementsByTagName("head")[0].appendChild(fileref)
}

function setpopupdata(productid,div)
{
       var datanow=datamain[productid];
       targetdiv='#main-middle';
if(div)
{
      targetdiv=div;
}else
{

statdataweb(productid);



}



$(targetdiv+' .wrpCommentTarget').hide();



if(typeof  allowuser[productid]== "undefined")
{
allowuser[productid]=new Array();

}
setbannerlandingfeature(datanow.fid,targetdiv);


//console.log(productid);

$('.ovlPopLd '+targetdiv+' .ttlLd.fs11.clTxt2').html(datanow.title);

if(datanow['tag'].length)
{
var tagstr="";
$.each(datanow['tag'], function(key, value) {
tagstr+='<a href="'+baseinfo+'/tag/'+value.name+'" target="_blank"> #'+value.name+'</a>';

});
$('.ovlPopLd '+targetdiv+' .ldIt.wrpItTaglLd p.desLd').html("Tag "+tagstr);
}

$('.ovlPopLd '+targetdiv+' .byUpdtLd img.genImgUser').attr('src',datanow.userssimg.newpath);
$('.ovlPopLd '+targetdiv+' .byUpdtLd span:eq(0)').html(datanow.displayname);
$('.ovlPopLd '+targetdiv+' .byUpdtLd span:eq(0)').attr("onclick",'linkto(\''+baseinfo+'/'+datanow.username+'\')');
$('.ovlPopLd '+targetdiv+' .byUpdtLd span:eq(3)').html(datanow.newdate);
$('.ovlPopLd '+targetdiv+' .byUpdtLd span:eq(6)').html(datanow.countlike);
$('.ovlPopLd '+targetdiv+' .byUpdtLd span:eq(9)').html(datanow.countview);

$('.ovlPopLd '+targetdiv+' .displaynamelanding').html('<input type="hidden" name="nowproductid" value="'+productid+'" >Related post from Username :'+datanow.displayname);
$('.ovlPopLd '+targetdiv+' .tagstringdataset').html('Related post from #Hashtag :'+tagstr);
$('.ovlPopLd '+targetdiv+' .LandingOther').html('');

if(datanow.otherproduct.length)
{
var code='';
$.each(datanow.otherproduct, function(key, value) {
code += '<div class="wrpInImgSgtLd" >\n';
code += '<a href="'+baseinfo+'/'+value.link+'/'+value.productid+'"  >\n';
code += '<div class="hvrSgtLd clBgSp2">\n';
code += '<span class="clTxtW">'+value['title']+'</span>\n';
code += '</div>\n';
code += '<img class="imgSgtLd" src="'+value['img']['newpath']+'" alt="Img" width="100" height="100">\n';
code += '</a>\n';

code += '</div>';
});

$('.ovlPopLd '+targetdiv+' .LandingOther').html(code);
}


$('.ovlPopLd '+targetdiv+' .LandingRelate').html('');
if(datanow.relateproduct.length)
{
var code='';
$.each(datanow.relateproduct, function(key, value) {

code += '<div class="wrpInImgSgtLd" >\n';

code += '<a href="'+baseinfo+'/'+value.link+'/'+value.productid+'"  >\n';
code += '<div class="hvrSgtLd clBgSp2">\n';
code += '<span class="clTxtW">'+value['title']+'</span>\n';
code += '</div>\n';
code += '<img class="imgSgtLd" src="'+value['img']['newpath']+'" alt="Img" width="100" height="100">\n';
code += '</a>\n';

code += '</div>';
});

$('.ovlPopLd '+targetdiv+' .LandingRelate').html(code);
}


$('.ovlPopLd '+targetdiv+' .ldIt.wrpDesLd .desLd').html(datanow.description.replace(new RegExp('\n','g'), '<br />'));
$('.ovlPopLd '+targetdiv+' .ldIt.wrpPmtLd').hide();
$('.ovlPopLd '+targetdiv+' .ldIt.wrpOutPrcLd').hide();
$('.ovlPopLd '+targetdiv+' .wrpBodyLd.clBd2.bdBtm').html('');

var checkbookingnow=0;
if(typeof  datanow.feature!= "undefined")
{
     if(typeof  datanow.feature.isbooking!= "undefined")
     {
     
     $('.ovlPopLd '+targetdiv+' .bookingcontent').show();
     
     $( '.ovlPopLd '+targetdiv+' .bookingcontent input[name="checkindate"]').datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 1,
dateFormat:'dd/mm/yy',
onClose: function( selectedDate ) {
$(  '.ovlPopLd '+targetdiv+' .bookingcontent input[name="checkindate"]' ).datepicker( "option", "minDate", selectedDate );
}
});

    $( '.ovlPopLd '+targetdiv+' .bookingcontent input[name="checkoutdate"]' ).datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 1,
dateFormat:'dd/mm/yy',
onClose: function( selectedDate ) {
$(   '.ovlPopLd '+targetdiv+' .bookingcontent input[name="checkindate"]' ).datepicker( "option", "maxDate", selectedDate );
}
});
     
     checkbookingnow=1;
     }else
     {
     checkbookingnow=0;
     
     $('.ovlPopLd '+targetdiv+' .bookingcontent').hide();
     }


}else
{
checkbookingnow=0;
$('.ovlPopLd '+targetdiv+' .bookingcontent').hide();
}









if(datanow['plugins'].length)
{


//$.each(datanow['plugins'], function(key, value) {
//if($.isFunction("getform"+value.plugname))
//{


//}else
//{
//loadjscssfile('/js/plugins/'+value.plugname+'.js', 'js');

//}


//});


$.each(datanow['plugins'], function(key, value) {

eval("var rowdata=getform"+value.plugname+"(value)");

//console.log(value.plugname);


if(typeof rowdata != 'undefined'){

$('.ovlPopLd '+targetdiv+' .wrpBodyLd.clBd2.bdBtm').append(rowdata);
if(targetdiv=='#main-middle')
{
$('.ovlPopLd '+targetdiv).show();


}
}





});


}

//if(allowuser['productid-'+datanow.createbyd])

if(datanow.code!="")
{

if(datanow.createby!=useridinfo)
{

if($.inArray(useridinfo,allowuser[productid])==-1)
{



$('.ovlPopLd '+targetdiv+' .wrpCt.w640 .wrpHdLd.clBd2.bdBtm').hide();
$('.ovlPopLd '+targetdiv+' .wrpCt.w640 .wrpBodyLd.clBd2.bdBtm').hide();


if($('.ovlPopLd '+targetdiv+' .wrpCt.w640').hasClass('isCode'))
{

$('.ovlPopLd '+targetdiv+' .wrpCt.w640 .wrpInpCode').show();


}else
{
var code = '<div class="wrpInpCode">\n';
code += '<h2 class="fs04 clTxt2">Please Enter Code.</h2>\n';
code += '<input type="text" class="inpCodeData inpAddCtnt w630 clBg5 clBd2 fs03 clTxt2">\n';
code += '<input type="button" onclick="checkCodeData('+productid+')" class="btnGen clTxtW cutTxt clBgSp2 fs04" value="OK">\n';
code += '</div>';
$('.ovlPopLd '+targetdiv+' .wrpCt.w640').append(code);
$('.ovlPopLd '+targetdiv+' .wrpCt.w640').addClass("isCode");
}

}else
{
$('.ovlPopLd '+targetdiv+' .wrpCt.w640 .wrpHdLd.clBd2.bdBtm').show();
$('.ovlPopLd '+targetdiv+' .wrpCt.w640 .wrpBodyLd.clBd2.bdBtm').show();
$('.ovlPopLd '+targetdiv+' .wrpCt.w640 .wrpInpCode').hide();

}

}

}
else
{
$('.ovlPopLd '+targetdiv+' .wrpCt.w640 .wrpHdLd.clBd2.bdBtm').show();
$('.ovlPopLd '+targetdiv+' .wrpCt.w640 .wrpBodyLd.clBd2.bdBtm').show();
$('.ovlPopLd '+targetdiv+' .wrpCt.w640 .wrpInpCode').hide();

}



//$('.ovlPopLd .byUpdtLd span:eq(5)').html(datanow.updatedate);



}
function checkCodeData(productidnow)
{
var targetdivset="#main-middle";
var datanow=datamain[productidnow];
if($(".ovlPopLd "+targetdivset+" .inpCodeData").val()==datanow.code)
{
$('.ovlPopLd '+targetdivset+' .wrpCt.w640 .wrpInpCode').fadeOut();
$('.ovlPopLd '+targetdivset+' .wrpCt.w640 .wrpHdLd.clBd2.bdBtm').fadeIn();
$('.ovlPopLd '+targetdivset+' .wrpCt.w640 .wrpBodyLd.clBd2.bdBtm').fadeIn();

allowuser[productidnow].push(useridinfo); 
initalldata();
}else
{
console.log("Wrong Password");

}

}
function chageorderby(orderbyset)
{
    orderby=orderbyset;
    pagemain=1;
    fistcheck=0;
    lastcheck=0;
    
    

pagemain=1;

       enddata=0;
                        
       cellnum=0;

      process=0;
      targetdiv='';
     // checkfirstrowdata=0;
     var setordername='New';
    if(orderby==1)
    {
            setordername='Popular';
    }
     
     
    $(".sortnoneblock").html('Sort By '+setordername);
    $(".wrpCell.mainCell").html('');
    //datamain=new Array();
    
    datamain={};
    celldata=new Array();
    
    getmainproduct();
    
}
function getseachtag(tagidset,tagnameset)
{
      fistcheck=0;
      lastcheck=0;
    
      
      pagemain=1;
  

       enddata=0;
                        
       cellnum=0;

        process=0;
        targetdiv='';
        
        tagid[0]=tagidset;
        
        $(".wrpCell.mainCell").html('');
        $(".ttlB.ttlFt .txtTtlB.cutTxt").html(tagnameset);
    
    datamain={};
    celldata=new Array();
    
    getmainproduct();

}
function showalldata(shownamefeature)
{
   fistcheck=0;
      lastcheck=0;
    
      
      pagemain=1;
  

       enddata=0;
                        
       cellnum=0;

        process=0;
        targetdiv='';
        
        tagid=new Array();
        
        $(".wrpCell.mainCell").html('');
        $(".ttlB.ttlFt .txtTtlB.cutTxt").html(shownamefeature);
    
    datamain={};
    celldata=new Array();
    
    getmainproduct();


}
function setbannerlandingfeature(fid,targetdiv)
{

if(typeof  bannerlanding[fid]!= "undefined")
{

//console.log(bannerlanding[fid]);
$('.ovlPopLd '+targetdiv+' .bannerAdsLanding .adsLd').html('');


$.each(bannerlanding[fid], function(key, value) {

$('.ovlPopLd '+targetdiv+' .bannerAdsLanding .adsLd').append('<a href="javascript:statdatalink(\''+value['link']+'\','+value['bannerid']+')"><img src="'+value['img']+'" alt="ads img"></a> ');

});




$('.ovlPopLd '+targetdiv+' .bannerAdsLanding').show();
}else
{
$('.ovlPopLd '+targetdiv+' .bannerAdsLanding').hide();

}



}
var getbannerset={};


function getbannercell()
{
var productxhr=$.get(serviceinfo+'getbannercellbyfid', { fid:fid }, function(data) {  
 $.each(data['data'], function(key, value) {
 
 getbannerset[value.position]=value;
 
 });
});
return productxhr;

}
var datacheckrowbanner=1;
function getbannersetstr()
{
var code="";
if(typeof  getbannerset[datacheckrowbanner]!= "undefined")
{

code = '<div  class="wrpInCell wrpInCellHvr w238" onclick="statdatalink(\''+getbannerset[datacheckrowbanner].link+'\','+getbannerset[datacheckrowbanner].bannerid+')" >\n';
code += '<div  class="ovlCell w238"></div>\n';
code += '<img width="238" height="238" class="imgCell w238" src="'+getbannerset[datacheckrowbanner].img+'" alt="img" >\n';
code += '</div>';
datacheckrowbanner++;
code += getbannersetstr();

}
return code;

}


function dateToYMD(date) {
    var d = date.getDate();
    var m = date.getMonth() + 1;
    var y = date.getFullYear();
    return '' + (d <= 9 ? '0' + d : d) + '/' + (m<=9 ? '0' + m : m) + '/' +y ;
}

var d1todayset=new Date();
var strtodayset= dateToYMD(d1todayset);
var latarrset=new Array();
var latarrset2=new Array();
var rownearby=0;
var kmapcheck=0.01;
function searchStringInArray (str, strArray) {
    for (var j=0; j<strArray.length; j++) {
        if (strArray[j].match(str)) return j;
    }
    return -1;
}
function getmainproduct()
{
  var code="";
  $(".cellLoad.fs03").show();
  
  var productxhr=$.get(serviceinfo+'getproduct', { page:pagemain,fid:fid,feed:feed,userid:userid,fav:fav,tagid:tagid,search:searchtext,orderby:orderby,lat:latset,lng:lngset,distance:distanceset,tagname:tagarrname,proid:proidset,duid:duidset,trip:tripset,budid:budidset,tagnamesearch:tagnamesearch,exifdatasearch:exifdatasearch,exifdatawhere:exifdatawhere }, function(data) {  
 
 if(data.data.length>0)
 {
       $.each(data['data'], function(key, value) {
       
       if(fistcheck==0)
       {
          fistcheck=value.productid;
         
       }
          lastcheck=value.productid;
       
       datamain[value.productid]=value;
       celldata[cellnum]=value.productid;
       
       $.uniquedata(celldata[cellnum]);
       
       
       cellnum++;
       var setclasscheck="wrpInCellHvr";
              if(typeof isedit != 'undefined')
             {
            // console.log('test my'+myuserid);
            // console.log('test data'+value.createby);
             if(myuserid==value.createby||myuserroleid==3)
             {
             
             setclasscheck="wrpInCellEdt";
             }
             
             }
             code +=getbannersetstr();
             datacheckrowbanner++;
             
             code += '<div class="wrpInCell '+setclasscheck+' w238" id="wrpInCell-'+value.productid+'"  >\n';
             code += '<div class="ovlCell w238" onclick="openpopupdata('+value.productid+')" ></div>\n';
             code += '<img width="238" onclick="openpopupdata('+value.productid+')" height="238" alt="img" src="'+value.simg.newpath+'" class="imgCell w238">\n';
             
             if(value['show'])
             {
             var rowprc=1;
             var txtclass="";
             $.each(value['show'], function(key2, value2) {
             
             if(value2)
             {
             if(rowprc==1&&key2!='map')
             {
              txtclass="prc";
             
             }else
             {
               txtclass="dtnc";
             }
             
             if(value2!=0.00)
             {
             code += '<div class="'+txtclass+'Cell fs03 clTxtCell">'+value2+'</div>\n';
             }
             
             
             }
             
             
             
             });
             }
             else
             {
             if(typeof value.close != 'undefined')
             {
             if(value.close=='1')
             {
             code += '<div class="prcCell fs03 clTxtCell">Closed</div>\n';
             }
             
             
             }
             if(typeof value.countcomment != 'undefined')
             {
             code +='<div class="wrpCmtCell"><i class="ico icoCmtCell"></i><span class="numCmtCell fs03 clTxtCell">'+value.countcomment+'</span></div>';
             }
             
             }
             
             if(nearbyme=="1")
             {
                     
                    if(value['plugins'].length>0)
                    {
                    var checkplugins=1;
                   $.each(value['plugins'], function(key2, value2) {
                       if(value2['plugid']=="5"&&checkplugins==1)
                       {
                            var latsetnow2=value2['lat'];
                            var lngsetnow2=value2['lng'];
                            if(searchStringInArray(latsetnow2+'|'+lngsetnow2,latarrset2)!=-1)
                            {
                            
                                  latsetnow2=parseFloat(latsetnow2)+kmapcheck;
                                  lngsetnow2=parseFloat(lngsetnow2)+kmapcheck;
                                  kmapcheck=kmapcheck+0.01;
                                  
                            }
                            
                            latarrset2[rownearby]=latsetnow2+'|'+lngsetnow2; 
                            
                            latarrset2
                            checkplugins=0;
                            
                            //var codemap = '<div class="wrpPopPointMap clBg5" onclick="openpopupdata('+value.productid+')">\n';
//                            codemap += '<div class="triPoint"></div>\n';
//                            codemap += '<span class="spnPointMap fs03 clTxt3">'+(rownearby+1)+'</span>\n';
//                            codemap += '<div class="closePointMap">\n';
//                            codemap += '<span class="ico icoCloseGen"></span>\n';
//                            codemap += '</div>\n';
//                            codemap += '<img src="'+value.simg.newpath+'" alt="img">\n';
//                            codemap += '<span class="spnPostPointMap fs03">'+value.title+'</span>\n';
//                            codemap += '</div>';
                            
                            
                            var codemap = '<div class="wrpPopPointMap" onclick="openpopupdata('+value.productid+')">\n';
                            codemap += '<span class="spnPointMap fs03 clTxt3">'+(rownearby+1)+'</span>\n';
                            codemap += '<img src="'+value.simg.newpath+'" alt="img">\n';
                            codemap += '<span class="spnPostPointMap fs03">'+value.title+'</span>\n';
                            codemap += '</div>';
                            

                            
                            latarrset[rownearby]= {latLng:[latsetnow2, lngsetnow2],data:codemap,options:{icon: "http://maps.google.com/mapfiles/marker_green.png"}}
                            rownearby++;
                           
                       }
                   
                   });
                   
                   }
             
             }
             
             if(typeof isedit != 'undefined')
             {
            // console.log('test my'+myuserid);
            // console.log('test data'+value.createby);
             if(myuserid==value.createby||myuserroleid==3)
             {
             var featurelink="feature";
             if(value.feature)
             {
             featurelink=value.feature.link;
             
             }else
             {
             featurelink="feature";
             
             }
             code +='<div class="wrpTl wrpBtnEdtCell"><div title="Remove" onclick="deleteproduct('+value.productid+')" class="btnIco closeTl clBd3 bdBtm"><span class="ico icoCloseTl"></span></div><div title="Edit" class="btnIco edtCell" onclick="location.href=\''+baseinfo+'/'+featurelink+'/add/'+value.productid+'?nocahce=1\'"><span class="ico icoEdtCell"></span></div></div>';
             
             }
             
             }
            // code += '<div class="dtncCell fs03 clTxtCell">150 km</div>\n'; 
 
             if(strtodayset==value.newdatecreate)
             {
             code += '<div class="newCell clTxtW clBgSp2 fs07">NEW</div>\n';  
             }       
             
                        
             code += '<div class="ldTtlCell fs09 clTxtCell cutTxt" onclick="openpopupdata('+value.productid+')">'+value.title+'</div>\n';
             code += '<div class="authCell fs03 clTxtCell" onclick="openpopupdata('+value.productid+')">\n';
             code += '<img width="36" height="36" alt="User Image" class="imgUserCell" src="'+value.userssimg.newpath+'">\n';
             code += '<span onclick="linkto(\''+baseinfo+'/'+value.username+'\')" class="authName cutTxt">'+value.displayname+'</span>\n';
           //  code += '<span class="proUser proCell clBgSp2 clTxtW fs01">Pro</span>\n';
             code += '</div>\n';
             
               var classchecklike="";
             if(value.checklike)
             {
             classchecklike="icoLikeW";
             }
             
             code += '<div class="wrpLikeCell '+classchecklike+'" onclick="favfunction('+value.productid+')">\n';
           
             
             code += '<i class="ico icoUnLikeW"></i>\n';
             
             code += '<span class="numLikeCell fs03 clTxtCell">'+value.countlike+'</span>\n';
             
             
             code += '</div>\n';
             code += '</div>';
       
       
       
      
      });
       
       $(".wrpCell.mainCell").append(code);
       if(nearbyme=="1")
             {
                   $("#mapNearBnn").gmap3('destroy');
                   setlatlngnearby();
             
             }
       checkfirstrowdata=1;
       enddata=0;
 }else
 {
 enddata=1;
 
 }
  if(checkfirstrowdata==0)
  {
  
  
  code='<div class="nodata"><span class="cltxt3 fs04">No data</span></div>';
  $(".wrpCell.mainCell").html(code);
  
  if(nearbyme=="1")
             {
                   $("#mapNearBnn").gmap3('destroy');
                   
             
             }
  
  }
  $(".cellLoad.fs03").hide();
 
 });
  
  
 return productxhr;


}
function getmainproductforum()
{
  var code="";
 // $(".cellLoad.fs03").show();
  $('').insertAfter( "#forumtable" );
  var productxhr=$.get(serviceinfo+'getproduct', { page:pagemain,fid:fid,feed:feed,userid:userid,fav:fav,tagid:tagid,search:searchtext,orderby:orderby,lat:latset,lng:lngset,distance:distanceset,tagname:tagarrname,proid:proidset,duid:duidset,trip:tripset,budid:budidset,tagnamesearch:tagnamesearch }, function(data) {  
 
 if(data.data.length>0)
 {
 var rowcheckclass=1;
 var classsetforum='clBg3';
 var settextstricky='Sticky';
 var textlastcomment='';
       $.each(data['data'], function(key, value) {
       
       if(fistcheck==0)
       {
          fistcheck=value.productid;
       }
          lastcheck=value.productid;
       
       datamain[value.productid]=value;
       celldata[cellnum]=value.productid;
       
       $.uniquedata(celldata[cellnum]);
       cellnum++;
classsetforum='clBg3';      
if(rowcheckclass%2)
{
classsetforum='clBg2';  
}      
rowcheckclass++;

settextstricky='';

if(value.position!="0")
{
settextstricky= '<span class="clBgSp2 clTxtW fs01">Sticky</span>\n';

}
       
code += '<tr class="wrpForum '+classsetforum+'">\n';
code += '<td class="hotForum">\n';
code += ''+settextstricky+'\n';
code += '</td>\n';
code += '<td class="ttlForum fs04">\n';
code += '<a href="javascript:void(0)" onclick="openpopupdata('+value.productid+')"><span class="boldGen">'+value.title+'</span></a>\n';
code += '<span class="cutTxt">'+value.description+'</span>\n';
code += '</td>\n';
code += '<td class="authForum fs03 clearfix">\n';
code += '<a href="'+baseinfo+'/'+value.username+'"  target="_blank"><span class="spnAuthForum boldGen">'+value.displayname+'</span></a>\n';
code += '</td>\n';
code += '<td class="dateForum fs03">\n';
code += '<span>'+value.newdate+'</span>\n';
code += '<span>'+value.timedate+'</span>\n';
code += '</td>\n';
code += '<td class="viewForum fs03">\n';
code += '<span>'+value.countview+'</span>\n';
code += '</td>\n';
code += '<td class="LikeForum fs03">\n';
code += '<span>'+value.countlike+'</span>\n';
code += '</td>\n';
code += '<td class="cmtForum fs03">\n';
code += '<span>'+value.countcomment+'</span>\n';
code += '</td>\n';
code += '<td class="lastCmtForum fs02">\n';

textlastcomment='';
if(value['plugins'].length)
{

$.each(value['plugins'], function(key2, value2) {

if(value2['plugname']=="comment")
{
if(value2['comment'].length)
{


$.each(value2['comment'], function(key3, value3) {
//textlastcomment='';
//textlastcomment+='';
//textlastcomment+='';
if(textlastcomment=='')
{
textlastcomment='';
textlastcomment += '<a  href="'+baseinfo+'/'+value3.username+'"  target="_blank"><span class="boldGen">'+value3.displayname+'</span></a>\n';


var res = value3.newdate.split(" "); 

textlastcomment += '<span class="fs01">'+res[0]+'</span>\n';
textlastcomment += '<span class="fs01">'+res[1]+'</span>\n';
}


});



}





}



});

}


code += textlastcomment;


code += '</td>\n';
code += '</tr>';
     
            
           

       
       
       
      
      });
       
      // $(".wrpCell.mainCell").html(code);
       
       $(code).insertAfter( "#forumtable" );
       
        if(pagemain==1)
     {
      //  console.log(1);
       setpagination('.wrpInPageForum.fs04',data['page'],1,'changepageforumdata',0,0,'');
     }
       
   
 }else
 {

 
 }

 
 
 });
  
  
 return productxhr;


}
function getmaintagrow()
{
var code='';
  var productxhr=$.post(serviceinfo+'loadnewgrouptag', { page:pagemain,fid:fid }, function(data) {
if(data.data.length)
{

$.each(data.data, function(key, value) {

code += '<div class="wrpLstTagP" style="width:203px;height:203px;margin:10px">\n';
code += '<a href="'+baseinfo+'/tag/'+value.tag+'">\n';
code += '<div class="wrpInLstTagP">\n';
code += '<div class="imgTagP">\n';
code += '<img alt="" src="'+value.simg.newpath+'">\n';
code += '</div>\n';
code += '<div class="nameTagP">\n';
code += '<span class="boldGen cutTxt clTxt1 fs05">#'+value.tag+'</span>\n';
code += '</div>\n';
code += '</div>\n';
code += '</a>\n';
code += '</div>';

});


$('.wrpTagP .wrpBdTagP.clearfix').html(code);

}


  });
  
  return productxhr;

}
function changepageforumdata(pagedata,parem1,parem2)
{
pagemain=pagemain;
getmainproductforum();

}
function setlatlngnearby()
{

var latLng={lat:latset,lng:lngset}; 
$('#mapNearBnn').gmap3({
                  marker:{ 
                    latLng:latLng,
                    options:{
                        draggable: false
                    },
                    
                    
                    
                    },
                      map:{
                        options:{
                          zoom: 15,
                          center :latLng
                        }
                      }
                });

$("#mapNearBnn").gmap3({
    marker:{
    values:latarrset,
    options:{
      draggable: false
    },
     cluster:{
      radius: 100,
      events:{ // events trigged by clusters
        click:function(cluster, event, data) {

        
        
                $(this).gmap3({
                      map:{
                        options:{
                          zoom: cluster.main.map.getZoom()+2,
                          center :data.data.latLng
                        }
                      }
                });
        
     //   cluster.map.panTo(data.latLng);
        //cluster.map.setZoom(cluster.map.getZoom()+2);
      }
      },
      0: {
        content: "<div class='cluster cluster-1'>CLUSTER_COUNT</div>",
        width: 53,
        height: 52
      }
    },
    events:{
      click: function(marker, event, context){
        var map = $(this).gmap3("get"),
          infowindow = $(this).gmap3({get:{name:"infowindow"}});
        if (infowindow){
          infowindow.open(map, marker);
          infowindow.setContent(context.data);
        } else {
          $(this).gmap3({
            infowindow:{
              anchor:marker,
              options:{content: context.data}
            }
          });
        }
      }
    }
  }
});


}
function gettagproduct()
{
var productxhr=$.get(serviceinfo+'gettagproduct', { page:pagemain,fid:fid,tag:tag }, function(data) { 
var code="";
var firstcheckimg=1;
  if(data.data.length>0)
 {
 var setlink="/tag";
 if(targetusername)
{

setlink=targetusername+setlink;

}

var datasetlink="";
 $.each(data['data'], function(key, value) {

if(featurename)
{

datasetlink=setlink+'/'+value.name+'/'+featurename;

}else
{
datasetlink=setlink+'/'+value.name;

}
code += '<div class="wrpTag" onclick="location.href=\''+baseinfo+'/'+datasetlink+'\'">\n';
code += '<div class="wrpImgTag">\n';

if(value.arrayimg.length>0)
{
firstcheckimg=1;
    $.each(value.arrayimg, function(key2, value2) {
 if(firstcheckimg==1)
 {   
code += '<img width="158" height="158" alt="img" src="'+value2.newpath+'" class="bigImgTag">\n';
firstcheckimg=0;
 }else
 {
 code += '<img width="79" height="79" alt="img" src="'+value2.newpath+'" class="smlImgTag1">\n';
 
 }



    });
}
code += '</div>\n';
code += '<div class="wrpNameTag clBg5 clTxt2">\n';
code += '<span class="nameTag fs07 cutTxt">'+value.name+'</span>\n';
code += '<span class="fs03">'+value.countprouduct+' Cells</span>\n';
code += '</div>\n';
code += '</div>';

       });
       
       $(".wrpCell.mainCell").append(code);
       checkfirstrowdata=1;
 }else
 {
 enddata=1;
 
 }
  if(checkfirstrowdata==0)
  {
  code='<div class="nodata"><span class="cltxt3 fs04">No data, please add content.</span></div>';
  $(".wrpCell.mainCell").html(code);
  
  }
  $(".cellLoad.fs03").hide();
 

});
return productxhr;

}

function getmylocation()
{


}
function likefunction(productid)
{

//loaddata();
$.post(serviceinfo+'likeproduct', { productid:productid }, function(data) { 
//loadclosedata();
if(data.error.response)
{
if(data.error.error[0].code==5)
{
$('.ovlPopLd').hide();
$('.wrpPopLI').fadeIn();

//console.log('test');
}else
{
//alertbox(data.error.error);

alertbox(data.error.error);
}

}
else
{

boxmsgdata('Success');

var data=data.data;
var getdata=datamain[productid];
if(typeof  getdata!= "undefined")
{
getdata.checkbookmark=data.checklike;
getdata.countbookmark=data.countlike;
}

$('.genMenuListPop.numBmFlw.numBm .btnNumBmFlw').html(data.countlike+' Bookmark');


//$('#wrpInCell-'+productid+'   .numLikeCell').html(data.countlike);
if(data.checklike)
{
$('.wrpBmLd   span.ico').addClass('icoUnBmLd');
//$('#wrpInCell-'+productid+'   .wrpLikeCell ').addClass('icoLikeW');
}else
{
$('.wrpBmLd  span.ico').removeClass('icoUnBmLd');
//$('#wrpInCell-'+productid+'   .wrpLikeCell ').removeClass('icoLikeW');
} 
}


});

}
function favfunction(productid)
{

//loaddata();
$.post(serviceinfo+'favproduct', { productid:productid }, function(data) { 

//loadclosedata();
if(data.error.response)
{
if(data.error.error[0].code==5)
{
$('.ovlPopLd').hide();
$('.wrpPopLI').fadeIn();

//console.log('test');
}else
{
//alertbox(data.error.error);

alertbox(data.error.error);
}

}
else
{

boxmsgdata('Success');

var data=data.data;
var getdata=datamain[productid];
if(typeof  getdata!= "undefined")
{
getdata.checklike=data.checklike;
getdata.countlike=data.countlike;
}


$('.genMenuListPop.numLikeFlw.numLike .btnNumLikeFlw').html(data.countlike+' Like');
$('#wrpInCell-'+productid+'   .numLikeCell').html(data.countlike);
if(data.checklike)
{
$('.wrpLikeLd   span.ico').addClass('icoLikeLd');
$('#wrpInCell-'+productid+'   .wrpLikeCell ').addClass('icoLikeW');
}else
{
$('.wrpLikeLd  span.ico').removeClass('icoLikeLd');
$('#wrpInCell-'+productid+'   .wrpLikeCell ').removeClass('icoLikeW');
} 
}


});

}
function followfunction(productid,userid)
{
var userdatasetfollowcheck2='';
if(typeof  userdatasetfollowcheck!= "undefined")
{
     userdatasetfollowcheck2=userdatasetfollowcheck;

}
if(userid)
{
//loaddata();
$.post(serviceinfo+'followuser', { userid:userid,userdatasetfollowcheck:userdatasetfollowcheck2 }, function(data) { 
//loadclosedata();




if(data.error.response)
{
if(data.error.error[0].code==5)
{
$('.ovlPopLd').hide();
$('.wrpPopLI').fadeIn();

//console.log('test');
}else
{
alertbox(data.error.error);
}
}
else
{
boxmsgdata('Success');
var data=data.data;
if(productid)
{

var getdata=datamain[productid];
if(typeof  getdata!= "undefined")
{
getdata.checkfollow=data.checkfollow;
getdata.countfollow=data.countfollow;
}

$('.genMenuListPop.numLikeFlw.numFlw .btnNumLikeFlw').html(data.countfollow+' Follow');
if(data.checkfollow==3)
{
$('.wrpFlwLd  span.ico').addClass('icoFlwWaitLd');

}
else if(data.checkfollow)
{
$('.wrpFlwLd  span.ico').addClass('icoFlwedLd');

}
else
{
$('.wrpFlwLd  span.ico').removeClass('icoFlwedLd');
$('.wrpFlwLd  span.ico').removeClass('icoFlwWaitLd');

} 
}
else
{
$('.wrpNumFlwerPf .fs11').html(data.countfollow);
$('#tgFlwHdGen2 span').html(data.countfollowing);
if(data.checkfollow==3)
{
$('.fMEPf .ico.icoUnFlwPf').addClass('icoFlwWaitPf');
$('.btnIco.flwEmt.clBgBt1 .ico.icoFlwPl').addClass('icoFlwWaitPf');
$('#flwGen-'+userid+' .ico.icoFlwPl').addClass('icoFlwWaitPf');

$('#flwGen-'+userid+' .ico.icoFlwPl').attr('title','Wait');

}
else if(data.checkfollow)
{
$('.fMEPf .ico.icoUnFlwPf').addClass('icoFlwPf');

$('.btnIco.flwEmt.clBgBt1 .ico.icoFlwPl').addClass('icoFlwed');

$('#flwGen-'+userid+' .ico.icoFlwPl').addClass('icoFlwed');


$('#flwGen-'+userid+' .ico.icoFlwPl').attr('title','UnFollow');

}else
{
$('.fMEPf .ico.icoUnFlwPf').removeClass('icoFlwPf');
$('.fMEPf .ico.icoUnFlwPf').removeClass('icoFlwWaitPf');


$('.btnIco.flwEmt.clBgBt1 .ico.icoFlwPl').removeClass('icoFlwed');
$('.btnIco.flwEmt.clBgBt1 .ico.icoFlwPl').removeClass('icoFlwWaitPf');


$('#flwGen-'+userid+' .ico.icoFlwPl').removeClass('icoFlwed');
$('#flwGen-'+userid+' .ico.icoFlwPl').removeClass('icoFlwWaitPf');

$('#flwGen-'+userid+' .ico.icoFlwPl').attr('title','Follow');



} 

}

}
});
}
else
{
$('.ovlPopLd').hide();
$('.wrpPopLI').fadeIn();

}

}
function sharefunction(index,productid,link)
{
//console.log(index);
//console.log(productid);
var linkdata=baseinfo+'/post/'+productid;


var iOS = ( navigator.userAgent.match(/(iPad|iPhone|iPod)/g) ? true : false );
var newlink = document.createElement('a');

switch(index)
{

case 0:
   if(iOS)
   {
   
   window.location='http://www.facebook.com/sharer/sharer.php?v=4&src=bm&u='+linkdata,'Facebook','height=450,width=550';
   
   
   
   
   }else
   {
   
   window.open('http://www.facebook.com/sharer/sharer.php?v=4&src=bm&u='+linkdata,'Facebook','height=450,width=550').focus() ;
   }
 // window.open('/plans/individual/continue-to-ap-pop.asp','Continue_to_Application','width=200,height=400');
  
  break;
case 1:
  window.open('http://twitter.com/intent/tweet?source=webclient&text='+linkdata,'Twitter','height=450,width=550').focus() ;
  break;
case 2:
  window.open('https://plus.google.com/share?url='+linkdata,'Google +','height=450,width=550').focus() ;
  break;
  
  
case 3:
  
  $("#txtbroadcast").val(linkdata);
 // $(".ovlPopLd").fadeOut();
  openbroadcasting();
  break;
case 4:
console.log("test 4");
   //$(".ovlPopLd").fadeOut();
  $(".wrpPopEmbed").fadeIn();
  $(".wrpPopEmbed .frmTxtArea.frmGen").val(linkdata+'/embed');
  break;
case 5:

   //$(".ovlPopLd").fadeOut();
  $(".wrpPopQRCode").fadeIn();
  $(".wrpPopQRCode .wrpFrmGen").html('<img src="http://chart.apis.google.com/chart?chs=400x400&amp;cht=qr&amp;chld=|1&chl='+encodeURIComponent(linkdata)+'" alt="QR Code" />');
  break;

}


$.post(serviceinfo+'statdatashareweb', { productid:productid,caseid:index }, function(data) { 


});



}



 
